<template>
	<view>
		<view style="width: 100%;height: 50rpx;"></view>
		<u-dropdown @open="open">
			<u-dropdown-item  v-model="value2" title="街舞班花名册" @change="change" :options="options2"></u-dropdown-item>
			</u-dropdown>
		<view v-for="(item,index) in mingpie" :key="index" style="border: 0px solid red;width: 90%;height: 350px;margin-top: 60rpx;margin-left: 5%;background-color: #606266;border-radius: 10%;">
			
			<view style="width: 50%;height: 100%;border: 0px solid red;float: left;">
			<image style="width: 95%;margin-top: 50%;margin-left: 20rpx;border-radius: 5%;" mode="widthFix" :src="item.toxiang"></image>
			<u-button v-if="ytewr" @click="showw(index)" style="width: 250rpx;height: 50rpx;margin-top: 70rpx;background-color: #A0CFFF;">给学生评价</u-button>
			</view>
			<view style="width: 50%;height: 100%;border: 0px solid red;float: left;">
				<view v-if="item.pingjiashijian==''" style="width: 100%;height: 20rpx;border: 0px solid red;margin-top: 120rpx;"></view>
				<view v-if="item.pingjiashijian!=''" style="width: 100%;height: 20rpx;border: 0px solid red;margin-top: 40rpx;"></view>
				<view style="width: 100%;border: 0px solid red;color: #F3F4F6;"><span style="margin-left: 50rpx;">姓名</span><span style="margin-left: 10rpx;">:</span><span style="margin-left: 20rpx;">{{item.mingzi}}</span></view>
				<view style="width: 100%;border: 0px solid red;margin-top: 30rpx;color: #F3F4F6;"><span style="margin-left: 50rpx;">性别</span><span style="margin-left: 10rpx;">:</span><span style="margin-left: 20rpx;">{{item.xinbiee}}</span></view>
				<view style="width: 90%;border: 0px solid red;margin-top: 30rpx;color: #F3F4F6;margin-left: 50rpx;padding-right: 40rpx;"><span style="margin-left: 0rpx;">入学时间</span><span style="margin-left: 10rpx;">:</span><span style="margin-left: 20rpx;">{{item.ruxue}}</span></view>
				<view style="width: 100%;border: 0px solid red;margin-top: 30rpx;color: #F3F4F6;padding-right: 40rpx;"><span style="margin-left: 50rpx;">评价</span><span style="margin-left: 10rpx;">:</span>
				<view v-if="item.pingjia==''" style="margin-left: 50rpx;float: left;">暂时没有评价</view>	
				<view style="width: 100%;border: 0px solid red;color: #F3F4F6;margin-left: 50rpx;">{{item.pingjia}}</view>
				<view v-if="item.pingjiashijian!=''" style="margin-left: 50rpx;width: 100%;float: left;">评价时间<span style="margin-left: 10rpx;">:</span></view>
				<view style="margin-left: 50rpx;width: 100%;float: left;border: 0px solid red;">{{item.pingjiashijian}}</view>
				<u-popup v-model="show" mode="bottom" >
					<view style="width: 100%;height: 600rpx;">
						<view style="text-align: center;color: #000000;margin-top: 50rpx;font-size: 35rpx;font-weight:700 ;">请写上对{{xin}}的评价</view>
						<view style="color: #000000;text-align: center;margin-top: 30rpx;font-size: 30rpx;font-weight: 600;">{{nowTime}}{{nowWeek}}</view>
						<uni-easyinput style="margin-top: 50rpx;"  v-model="formData.password" type="textarea" textarea placeholder="请输入内容">		
						</uni-easyinput>
						<view @click="tijiaoshang(jiuj)" style="color: #000000;text-align: center;margin-top: 100rpx;font-size: 35rpx;font-weight: 700;">提交</view>
					<view v-if="niubi" style="color: red;text-align: center;font-size: 35rpx;font-weight: 700;margin-top: 40rpx;">评价成功！点击黑色地区将退出评价</view>
					<view v-if="formData.password==''" style="color: red;text-align: center;font-size: 35rpx;font-weight: 700;margin-top: 40rpx;">请输入完评价之后才点击提交</view>
					</view>
						</u-popup>
				</view>
			</view>
		</view>
        
		<!-- <uni-forms ref="form" :modelValue="formData" :rules="rules">

			<view class="s4">电话:</view>
			<uni-forms-item name="Phone" style="width: 50%;margin-left: 90px;">
				<uni-easyinput class="s3" type="number" v-model="formData.Phone" placeholder="请输入电话" />
			</uni-forms-item>
			<view class="s4">密码:</view>
			<uni-forms-item name="Password" style="width: 50%;margin-left: 90px;">
				<uni-easyinput class="s3" type="number" v-model="formData.Password" placeholder="请输入密码" />
			</uni-forms-item>
			<view class="s4">名称:</view>
			<uni-forms-item name="UserName" style="width: 50%;margin-left: 90px;">
				<uni-easyinput class="s3" type="text" v-model="formData.UserName" placeholder="请输入名字" />
			</uni-forms-item>
			<view class="s4">年龄:</view>
			<uni-forms-item name="Age" style="width: 50%;margin-left: 90px;">
				<uni-easyinput class="s3" type="number" v-model="formData.Age" placeholder="请输入年龄" />
			</uni-forms-item>
			<view class="s4">性别:</view>
			<uni-forms-item name="Gender" style="width: 50%;margin-left: 90px;">
				<uni-data-checkbox style="margin-top: 35px;margin-left: 15px;" v-model="formData.Gender" :localdata="range"
					@change="change"></uni-data-checkbox>
			</uni-forms-item>
			<view class="s4">班次:</view>
			<uni-forms-item name="banci" style="width: 50%;margin-left: 90px;">
				<uni-data-checkbox style="margin-top: 35px;margin-left: 5px;" v-model="formData.banci" :localdata="rangeee"
					@change="change"></uni-data-checkbox>
			</uni-forms-item>
			<view class="s4">头像:</view>
			<uni-forms-item name="Ico" style="width: 50%;margin-left: 90px;">
<uni-file-picker 
    v-model="imageValue" 
    fileMediatype="image" 
    mode="grid" 
  limit =1
/>
			</uni-forms-item>
			<view class="s4">舞种:</view>
			<uni-forms-item name="wuzhong" style="width: 50%;margin-left: 90px;">
				<uni-data-checkbox style="margin-top: 30px;margin-left: 10px;" multiple v-model="formData.wuzhong" :localdata="rangee"
					@change="change"></uni-data-checkbox>
			</uni-forms-item>
			<view class="s6" @click="submit">注册</view>
			<view style="width: 100%;height: 50px;"></view>
		</uni-forms> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mingpie:[],
				show: false,
				niubi:false,
				niubibi:false,
				ytewr:false,
				xin:"",
				nowWeek: '',
				nowTime: '',
				duilo:"",
				jiuj:"",
				zhuanyi:"",
				quchulaidezhi:"",
				value2: 2,
				options2: [],
					formData: {
						password:""
					}
			}
		},
		onLoad() {
			this.cha()
			
			
		},
		methods: {
			cha(){
				var that=this
				const db = uniCloud.database();
				db.collection("jiewuban")
				.get()
				.then(function(mcndd){
					
						that.mingpie=mcndd.result.data
						that.chuanguolai()
				})
			},
			showw(index){
				var that=this
				that.show=true
				var aa=that.mingpie[index].mingzi
				var bb=that.mingpie[index]._id
				that.jiuj=bb
				that.xin=aa
				
			},
			tijiaoshang(jiuj){
				var that=this
				var par={
					_id:jiuj
				}
				const db = uniCloud.database();
				db.collection("jiewuban")
				.where(par)
				.get()
				.then(function(eqww){
					if(that.nowTime!=""){
						
						var bb=that.nowTime
						var aa=that.nowWeek
						that.duilo=bb+aa
						var nvb=eqww.result.data
						that.jiexialai(nvb)
					}
					
				})
				// var par={
				// 	index:that.
				// }
				// const db = uniCloud.database();
				// db.collection("jiewuban")
				// .where(par)
				// .get()
				// .then(function(e){
					
				// })
			},
			jiexialai(nvb){
				
					var that=this
					var par={
						_id:nvb[0]._id,
					}
					var yyy={
						pingjia:that.formData.password,
						pingjiashijian:that.duilo
					}
					const db = uniCloud.database();
					db.collection("jiewuban")
					.where(par)
					.update(yyy)
					.then(function(yert){
						that.niubi=true
					})
				
				
			},
			currentTime () {
			  setInterval(this.getDate, 500)
			},
			getDate () {
			  const year = new Date().getFullYear()
			  const month = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : (new Date().getMonth() + 1)
			  const date = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
			  const hh = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours()
			  const mm = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
			  const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
			  const week = new Date().getDay()
			  this.nowTime = year + '年' + month + '月' + date + '日' + ' ' + hh + ':' + mm + ':' + ss
			  if (week === 1) {
			    this.nowWeek = '星期一'
			  } else if (week === 2) {
			    this.nowWeek = '星期二'
			  } else if (week === 3) {
			    this.nowWeek = '星期三'
			  } else if (week === 4) {
			    this.nowWeek = '星期四'
			  } else if (week === 5) {
			    this.nowWeek = '星期五'
			  } else if (week === 6) {
			    this.nowWeek = '星期六'
			  } else if (week === 27) {
			    this.nowWeek = '星期日'
			  }
			},
			chuanguolai(){
				var that=this
				
				var par={
					_id:uni.getStorageSync("jiushidaol")
				}
				const db = uniCloud.database();
				db.collection("tblUser")
				.where(par)
				.get()
				.then(function(e){
				
					var mnn = e.result.data
					console.log(mnn)
					if(mnn[0].Age>0){
						
						that.ytewr=false
					}else{
						that.ytewr=true
					}
					
					
					
				})
			}
			,open(index) {
				var that=this
				if(that.options2==""){
					console.log(index)
					that.zhongguowu()
				}
			
			},
			change(index){
				var that=this
				console.log(index)
			   for(var i=0;i<that.options2.length;i++){
				   var qqqqq=that.options2[i].value
				   console.log(qqqqq)
				   that.zhuanyi=qqqqq
				   console.log(that.zhuanyi-1)
				   var beerr=that.options2[i-1]
				    var beerrrr=that.options2[i]
				   console.log()
				   console.log(index[0])
				   if(that.zhuanyi-1==index[0]){
					   console.log("触发了2")
					   that.quchulaidezhi=beerr.label
					  
					   var par={
					   	mingzi:that.quchulaidezhi
					   }
					   const db = uniCloud.database();
					   db.collection("jiewuban")
					   .where(par)
					   .get()
					   .then(function(eve){
						   console.log("触发了")
					   uni.navigateTo({
					   	url:"../huamingche/huamingche?_id="+eve.result.data[0]._id
					   })
					   	
					   })
				   }else if(that.zhuanyi==index[0]){
					   console.log("触发了2")
					   that.quchulaidezhi=beerrrr.label
					   					  
					   var par={
					   	mingzi:that.quchulaidezhi
					   }
					   const db = uniCloud.database();
					   db.collection("jiewuban")
					   .where(par)
					   .get()
					   .then(function(eve){console.log("触发了")
					   uni.navigateTo({
					   	url:"../huamingche/huamingche?_id="+eve.result.data[0]._id
					   })
					   	
					   })
				   }
			   }
			},	
			zhongguowu(){
			var that=this;
			const db = uniCloud.database();
			db.collection("jiewuban")
			.get()
			.then(function(e){
				for(var i=0;i<e.result.data.length;i++){
					var aaa=[i]
					that.options2[that.options2.length] = {
						label: e.result.data[i].mingzi,
						value: aaa
					}
				}
				
			})
		}
		
			
		},
		mounted () {
		  this.currentTime()
		},
		// 销毁定时器
		beforeDestroy: function () {
		  if (this.getDate) {
		    clearInterval(this.getDate) // 在Vue实例销毁前，清除时间定时器
		  }
		}
	}
</script>

<style>
	/* .s1 {
		background-color: #FFFFFF;
		border-radius: 40px;
		width: 100%;
		height: 400px;
		margin-top: -100px;
	}

	.s2 {
		font-size: 20px;
		font-weight: 700;
		margin-top: 15px;
		margin-left: 25px;
	}

	.s3 {
		width: 250px;
		margin-top: 25px;
		float: left;
		margin-left: -5px;
		border: 1px solid #FF9900;
		border-radius: 10px;
	}

	.s4 {
		font-size: 15px;
		font-weight: 600;
		float: left;
		margin-top: 30px;
		padding-left: 30px;
	}

	.s6 {
		width: 330px;
		border: 1px solid #FCBD71;
		font-size: 18px;
		margin-left: 20px;
		margin-top: 20px;
		text-align: center;
		line-height: 40px;
		border-radius: 40px;
		color: #FCBD71;
		height: 40px;
		font-weight: 400;
	} */
</style>
